//
//  YSTopicItemToolView.m
//  Yueshi
//
//  Created by yueshi－mac1 on 15/12/7.
//  Copyright © 2015年 悦食中国. All rights reserved.
//

#import "YSTopicItemToolView.h"
#import "YSShareView.h"
#import "CustomShowView.h"
#import "WXClient.h"

@interface YSTopicItemToolView()
@property (weak, nonatomic) IBOutlet UIButton *shareWechat;
@property (weak, nonatomic) IBOutlet UIButton *shareMore;
@property (weak, nonatomic) IBOutlet UIButton *commentBtn;
@property (weak, nonatomic) IBOutlet UIButton *praiseBtn;

@end

@implementation YSTopicItemToolView

+(instancetype)toolView{
    return [[[NSBundle mainBundle] loadNibNamed:@"YSTopicItemToolView" owner:nil options:nil]lastObject];
}

-(void)setShareModel:(YSShareModel *)shareModel{
    _shareModel = shareModel;
}

- (void)setIsPraise:(NSInteger)isPraise{
    _praiseBtn.selected = isPraise;
//    if (isPraise) {
//        [_praiseBtn setImage:[UIImage imageNamed:@"icon_praise_red_s"] forState:UIControlStateNormal];
//    }else{
//        [_praiseBtn setImage:[UIImage imageNamed:@"icon_praise_s"] forState:UIControlStateNormal];
//    }
}

- (IBAction)onClick:(id)sender {
    switch (((UIButton *)sender).tag) {
        case 1: // 微信
            [[WXClient sharedClient]sendLinkContentWithURlStr:_shareModel.url andTitle:_shareModel.title andImageURL:_shareModel.imageUrl andDescription:_shareModel.subTile andScene:0];
            break;
        case 2:{ // 分享
            YSShareView *sv = [[YSShareView alloc]init];
            [sv setWidth:SCREENW];
            [sv setShareModel:_shareModel];
            CustomShowView *alertView =  [[CustomShowView alloc]initWithCustomView:sv location:CustomShowViewLocationBottomType];
            [alertView showWithAnim:YES];
            }
            break;
        case 3: // 点赞
            [[NSNotificationCenter defaultCenter] postNotificationName:kTopiclistPraiseNortif object:_indexPath];
            break;
        case 4: // 评论
            [[NSNotificationCenter defaultCenter] postNotificationName:kTopiclistCommentNortif object:_indexPath];
            break;
        default:
            break;
    }
}


@end
